<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Notice extends Controller_Initial_Page {

    public function action_ajax_index()
    {
        $user_model = Auth::instance()->get_user();
       
        //$time = time();
        //while((time() - $time) < 27)
        //{
            $notice_model = ORM::factory('notice');
            $notices = $notice_model->get_notices($user_model->id);
            
            
//            if($notices['amount_new_messages']      == $_POST['amount_new_messages'] AND 
//               $notices['amount_new_invitations']   == $_POST['amount_new_invitations'] AND 
//               $notices['amount_new_notifications'] == $_POST['amount_new_notifications'])
//            {
//                sleep(4);
//            }
//            else
//            {
                $this->response->body(json_encode($notices));
             //   break;
           // }   
        //}
    }
    
}